package com.wangxue.stock.job;


import com.wangxue.stock.service.StockTimerService;
import com.wangxue.stock.service.StockTimerTaskService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定义股票相关数据的定时任务
 * @author laofang
 */
@Component
public class StockJob {

    @Autowired
    private StockTimerTaskService stockTimerTaskService;

    @Autowired
    private StockTimerService stockTimerService;

    private static Logger logger = LoggerFactory.getLogger(StockJob.class);

    @XxlJob("csl_job_test")
    public void jobTest(){
        System.out.println("jobTest run.....");
    }

    /**
     * 获取大盘数据
     */
    @XxlJob("getInnerMarketInfo")
    public void getInnerMarketInfo(){
        stockTimerTaskService.getInnerMarketInfo();
    }
    /**
     * 定时采集A股数据
     */
    @XxlJob("getStockInfos")
    public void getStockInfos(){
        stockTimerService.getStockRtIndex();
    }
    /**
     * 板块定时任务
     */
    @XxlJob("getStockBlockInfoTask")
    public void getStockBlockInfoTask(){
        stockTimerService.getStockSectorRtIndex();
    }

    public void init(){
        logger.info("init");
    }

    public void destroy(){
        logger.info("destory");
    }
}
